RapidQ to Hotbasic migration

 

Tips to help migrate a RapidQ project to Hotbasic

 

topic

 

symptoms

solutions

Sub/Function declarations

in HB subs must always be declared, even if there are no forward calls (the sub statement itself isn’t used as a declaration).

If the sub  has arguments, the definition HB uses is the one in the declare statement

(same for functions)

add a declare statement before the sub/function implementation

variable names in sub arguments must not be used elsewhere with a different type

 

declare sub a1(x as integer)

declare sub a2(x as long)

 

will fail to compile. This is also true for API declarations (although arguments are mere placeholders in this case)

parse your code to avoid duplicates (can be very tedious)

Case-sensitivity

HB is case-sensitive, so that variable and function names must be exactly the same throughout

find/replace throughout your code

Reserved names

some names are reserved by HB and can’t be used. Non-exhaustive list includes:

ss, c, StartPage

 

using comment as a variable name doesn’t generate a compile error but causes an error while generating the object module

find/replace throughout your code

Compilation directives

$ifdef:

$resource inside $ifdefs are compiled anyway. As a result, you can’t use $ifdef to select between different resources

 

$ifdef English

  $resource lang as “english.txt”

$else

  $resource lang as “german.txt”

$endif

 

fails to compile (duplicate resource declaration)

? (no good solution so far)

Errors in str$() results

str$ sometimes yields strange results. str$ of an integer expression equal to 1 can return 0.999999999

problem is difficult to isolate: doesn’t appear systematically and doesn’t seem to appear on all computers

a)       try always calling str$ of a single variable:

    k=i+j : print str$(k)

    rather than: print str$(i+j)

(no guarantee that it eliminates all trouble)

 

b) write your own conversion sub for integers so you’re always safe

Operator precedence

Unlike anyone else, HB gives + precedence over –.

 

4 – 3 + 1 is evaluated as: 4 – (3+1) and thus gives 0 instead of 2

 

Same for *, which has precedence over /

parse your code and ensure that + appears before – in formulas. Same for * before / (very tedious)

 

Use the $equalprec on directive (this is a must, immediately after $typecheck on)

Ignoring function results

HB doesn’t allow ignoring function results, even for API functions (for which the result is merely the value of EAX on return)

 

E.g. sendmessage(h,WM_PAINT,0,0) fails to compile

a)       if you want to discard the result of a function, use a dummy variable to get the result

defint dummy= sendmessage(h,WM_PAINT,0,0)

 

b)       if you always ignore the result of a given function, then declare it as a sub. Also works for API functions:

declare sub SetFocus lib “user32” (h as integer)

 

Unsupported window styles

HB doesn’t support some window style keywords (like borderstyle, bevelinner, bevelouter, delbordericons)

a)       border: Use HB’s keywords style and exstyle to specify the border style you want. Common styles you may want to use:
no border:
style=&h50000000, exstyle=0
recessed edge, like an edit field:
style=&h50000000, exstyle=&h200, recreate
raised edge, like a panel:
exstyle=&h100

b)       delbordericons: set the style bits explicitly in property .style:
Ex:
thewnd.style= thewnd.style  and &hfffCffff 'remove WS_MAXIMIZEBOX and MINIMIZEBOX